package com.pingfangushi.kaptcha.spring.boot;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

import static com.pingfangushi.kaptcha.spring.boot.KaptchaPorperties.KAPTCHA_PREFIX;

/**
 * 属性配置
 *
 * @author SanLi
 * Created by 2689170096@qq.com on 2018/10/21 12:20
 */
@Data
@Slf4j
@ConfigurationProperties(prefix = KAPTCHA_PREFIX)
class KaptchaPorperties {

    /**
     * 指定前缀
     */
    static final String KAPTCHA_PREFIX = "spring.kaptcha";
    /**
     * 超时时间
     */
    private Integer expireDate = 60;
    /**
     * 宽度
     */
    private Integer width = 240;
    /**
     * 高度
     */
    private Integer height = 80;
    /**
     * 内容
     */
    @NestedConfigurationProperty
    private Content content = new Content();
    /**
     * 背景色
     */
    @NestedConfigurationProperty
    private BackgroundColor backgroundColor = new BackgroundColor();
    /**
     * 字体
     */
    @NestedConfigurationProperty
    private Font font = new Font();
    /**
     * 边框
     */
    @NestedConfigurationProperty
    private Border border = new Border();

    /**
     * 背景
     *
     * @author SanLi
     * Created by 2689170096@qq.com on 2018/10/21 14:25
     */
    @Data
    static class BackgroundColor {

        /**
         * 开始渐变色
         */
        private String from = "lightGray";
        /**
         * 结束渐变色
         */
        private String to = "white";

    }

    /**
     * 内容
     *
     * @author SanLi
     * Created by 2689170096@qq.com on 2018/10/21 14:25
     */
    @Data
    static class Content {

        /**
         * 内容源
         */
        private String source = "abcdefghjklmnopqrstuvwxyz123456789";
        /**
         * 内容长度
         */
        private Integer length = 4;
        /**
         * 内容间隔
         */
        private Integer space = 2;

    }

    /**
     * 边框
     *
     * @author SanLi
     * Created by 2689170096@qq.com on 2018/10/21 14:25
     */
    @Data
    static class Border {

        /**
         * 是否开启
         */
        private Boolean enabled = false;
        /**
         * 颜色
         */
        private String color = "black";
        /**
         * 厚度
         */
        private Integer thickness = 1;

    }

    /**
     * 字体
     *
     * @author SanLi
     * Created by 2689170096@qq.com on 2018/10/21 14:25
     */
    @Data
    static class Font {

        /**
         * 名称
         */
        private String name = "宋体,楷体,微软雅黑";
        /**
         * 颜色
         */
        private String color = "black";
        /**
         * 大小
         */
        private Integer size = 60;
        /**
         * 文字制片人实现
         */
        private String textProducerImpl = "com.google.code.kaptcha.impl.ShadowGimpy";

    }

}
